import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2025-01-16
 * Time: 11:23
 */
public class TwoSum {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>();
        int[] ret = new int[2];
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(target-nums[i])) {
                ret[0] = i;
                ret[1] = map.get(target-nums[i]);
                return ret;
            }
            map.put(nums[i], i);
        }
        return ret;
    }
}
